package com.cnpc.framework.base.entity;

import javax.persistence.*;

import com.cnpc.framework.annotation.ForeignShow;
import com.cnpc.framework.annotation.Header;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "tbl_function")
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler", "fieldHandler" })
public class Function implements Serializable,Comparable<Function>{

    /**
     *
     */
    private static final long serialVersionUID = 7823895619744279485L;

    @Id
    @GenericGenerator(name = "id", strategy = "uuid")
    @GeneratedValue(generator = "id")
    @Column(name = "id", length = 36)
    protected String id;


    /**
     * 版本号
     */
    @Version
    @Column(name = "version")
    protected Integer version;

    /**
     * 创建时间
     */
    @Column(name = "create_date_time")
    protected String createDateTime;

    /**
     * 最后修改时间
     */
    @Column(name = "update_date_time")
    protected String updateDateTime;

    /**
     * 删除标记(0启用，1禁用)
     */
    @Column(name = "deleted")
    private Integer deleted;

    @ForeignShow
    @Header(name = "名称")
    @Column(name = "name", length = 50)
    private String name;

    @Header(name = "编码")
    @Column(name = "code", length = 50)
    private String code;

    @Header(name = "url")
    @Column(name = "url", length = 200)
    private String url;

    @Header(name = "base")
    @Column(name = "base", length = 200)
    private String base;

    @Header(name = "父级ID")
    @Column(name = "parent_id")
    private String parentId;

    @Header(name = "层级编码")
    @Column(name = "levelCode", length = 36)
    private String levelCode;

    @Header(name = "图标")
    @Column(name = "icon")
    private String icon;

    // 0=目录 1=功能 2=按钮
    @Header(name = "菜单类型")
    @Column(name = "functype")
    private String functype;

    @Header(name="关联queryId")
    @Column(name="queryId")
    private String queryId;

    @Header(name = "备注")
    @Column(name = "remark", length = 1000)
    private String remark;

    @Transient
    private String parentName;

    @Transient
    private List<FunctionFilter> fflist;

    @Transient
    private String roleId;

    public String getQueryId() {
        return queryId;
    }

    public void setQueryId(String queryId) {
        this.queryId = queryId;
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public List<FunctionFilter> getFflist() {
        return fflist;
    }

    public void setFflist(List<FunctionFilter> fflist) {
        this.fflist = fflist;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {

        this.parentName = parentName;
    }

    public String getFunctype() {

        return functype;
    }

    public void setFunctype(String functype) {

        this.functype = functype;
    }

    public String getName() {

        return name;
    }

    public void setName(String name) {

        this.name = name;
    }

    public String getCode() {

        return code;
    }

    public void setCode(String code) {

        this.code = code;
    }

    public String getUrl() {

        return url;
    }

    public void setUrl(String url) {

        this.url = url;
    }

    public String getParentId() {

        return parentId;
    }

    public void setParentId(String parentId) {

        this.parentId = parentId;
    }

    public String getLevelCode() {

        return levelCode;
    }

    public void setLevelCode(String levelCode) {

        this.levelCode = levelCode;
    }

    public String getIcon() {

        return icon;
    }

    public void setIcon(String icon) {

        this.icon = icon;
    }

    public String getRemark() {

        return remark;
    }

    public void setRemark(String remark) {

        this.remark = remark;
    }

    public String getBase() {
        return base;
    }

    public void setBase(String base) {
        this.base = base;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public String getCreateDateTime() {
        return createDateTime;
    }

    public void setCreateDateTime(String createDateTime) {
        this.createDateTime = createDateTime;
    }

    public String getUpdateDateTime() {
        return updateDateTime;
    }

    public void setUpdateDateTime(String updateDateTime) {
        this.updateDateTime = updateDateTime;
    }

    public Integer getDeleted() {
        return deleted;
    }

    public void setDeleted(Integer deleted) {
        this.deleted = deleted;
    }

    @Override
    public String toString() {
        return "Function{" +
                "id='" + id + '\'' +
                ", version=" + version +
                ", createDateTime='" + createDateTime + '\'' +
                ", updateDateTime='" + updateDateTime + '\'' +
                ", deleted=" + deleted +
                ", name='" + name + '\'' +
                ", code='" + code + '\'' +
                ", url='" + url + '\'' +
                ", base='" + base + '\'' +
                ", parentId='" + parentId + '\'' +
                ", levelCode='" + levelCode + '\'' +
                ", icon='" + icon + '\'' +
                ", functype='" + functype + '\'' +
                ", queryId='" + queryId + '\'' +
                ", remark='" + remark + '\'' +
                ", parentName='" + parentName + '\'' +
                ", fflist=" + fflist +
                ", roleId='" + roleId + '\'' +
                '}';
    }

    @Override
    public int compareTo(Function o) {
        return this.levelCode.compareTo(o.levelCode);
    }
}
